<?php
/**
 * Form for adding and editing address
 */
class Page_Form_Category extends App_Form_FormAbstract
{
    /**
     * @see    Zend_Form::init()
     * @return void
     */
    public function init()
    {
 	
	    $this->setAttrib('id', 'registerform');
	    
	    $id = $this->addElement('hidden', 'id')->id;
	    
		$title = $this->addElement('text', 'title', array(
		    'label'=>'Title',
			'required' 	=> true,
		))->title;	

		$formName = $this->addElement('text', 'form_name', array(
		    'label'=>'form_name'
		))->form_name;	
		
		$description = $this->addElement('textarea', 'description', array(
		    'label'=>'Description',
			'class'=>'description'
		))->description;
		
		$content = $this->addElement('textarea', 'content', array(
		    'label'=>'Content',
		))->content;
			
		$parent = $this->addElement('text', 'parent', array(
		    'label'=>'Parent'
		))->parent;
		
		$preview = $this->addElement('text', 'preview', array(
		    'label'=>'Preview'
		))->preview;
		
		$order = $this->addElement('text', 'order', array(
		    'label'=>'Order'
		))->order;
		
		$isvisible = $this->addElement('checkbox', 'isvisible', array(
		    'label'=>'Is visible'
		))->isvisible;
		
		 $this->addElement('submit', 'page_form_category', array(
		    'label'=>'Enregistrer'
		));						        
    }
    
    public function getTablePreparedData(array $data)
    {
    	$result = $data;
    	
    	unset($result['page_form_category']);
    	unset($result['id']);
    	
    	return $result;
    }
    
    public function populateByCategoryId($categoryId)
    {
    	$category = new Page_Model_Category();
    	$data = $category->fetchById($categoryId);
    	$this->populate($data);
    }
}
